package com.etl.controller;

import com.etl.entity.EtlTaskLog;
import com.etl.service.IEtlLogService;
import com.etl.util.ResponseUtil;
import com.etl.util.ResultVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2019/10/21.
 */
@RestController
@RequestMapping("/etlLog")
@Api(tags = {"全量任务管理"}, value = "任务配置相关接口")
public class EtlLogController {

    @Autowired
    private IEtlLogService etlLogService;


    @ApiOperation(value = "查询某任务执行历史")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "kid", value = "任务主键", example = "13", required = true),
            @ApiImplicitParam(paramType = "query", name = "pages", value = "页数", example = "1", required = true),
            @ApiImplicitParam(paramType = "query", name = "sizes", value = "数量", example = "10", required = true),
            @ApiImplicitParam(paramType = "query", name = "logType", value = "数量", example = "10", required = true)
    })
    @GetMapping(value = "/history")
    public ResultVO<PageInfo<EtlTaskLog>> history(Integer pages, Integer sizes, Long kid, String logType) {

        PageInfo<EtlTaskLog> historyPage = etlLogService.history(pages, sizes, kid,logType);
        return ResponseUtil.success(historyPage);
    }



    @ApiOperation(value = "查询任务某次执行详情")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "logId", value = "日志主键", example = "13", required = true),
    })
    @GetMapping(value = "/historyDetail")
    public ResultVO<String> historyDetail(Long logId) {
        return ResponseUtil.success(etlLogService.historyDetail(logId));
    }



}

